package cc.yugu.yhdw.common.domain.basic;

import cc.yugu.yhdw.common.domain.LongIdEntity;
import cc.yugu.yhdw.common.entity.json.DateTimeSerializer;
import org.codehaus.jackson.map.annotate.JsonSerialize;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 客户出入流水帐
 *
 * @Date:Created in 2018/7/3 11:13
 * @Author:
 * @Modified By: zxj 2018/7/3 11:13
 */
public class CustomerInOutMoney extends LongIdEntity {

    public enum BizType {
        IN_MONEY_ONLINE(1, "在线充值"),
        IN_MONEY_OFFLINE(2, "线下充值"),
        CUSTOMER_EXCHANGE_PAY_BY_CASH_BALANCE(3, "换电支付(金额)"),
        CUSTOMER_EXCHANGE_PAY_BY_EXCHANGE_BALANCE(4, "换电支付(换电金额)"),
        CUSTOMER_EXCHANGE_REFUND_BY_CASH_BALANCE(5, "换电退款(金额)"),
        CUSTOMER_EXCHANGE_REFUND_BY_EXCHANGE_BALANCE(6, "换电退款(换电金额)"),
        CUSTOMER_EXCHANGE_BESPEAK_PAY_BY_CASH_BALANCE(7, "换电预约支付(金额)"),
        CUSTOMER_EXCHANGE_BESPEAK_PAY_BY_EXCHANGE_BALANCE(8, "换电预约支付(换电金额)"),
        CUSTOMER_ITEM_PAY(9, "商品支付"),
        CUSTOMER_ITEM_REFUND(10, "商品退款"),
        IN_EXCHANGE_MONEY(11, "换电金额"),
        DEPOSIT_GIFT_MONEY(12, "充值优惠"),
        CUSTOMER_EXCHANGE_PACKET_ORDER_REFUND(13, "换电套餐退款"),
        CUSTOMER_EXCHANGE_PACKET_ORDER_PAY(14, "换电套餐支付"),
        CUSTOMER_FOREGIFT_PAY(15, "押金支付"),
        CUSTOMER_FOREGIFT_REFUND(16, "押金退款"),
        ;

        private final int value;
        private final String name;

        private BizType(int value, String name) {
            this.value = value;
            this.name = name;
        }

        private static Map<Integer, String> map = new HashMap<Integer, String>();
        static {
            for (BizType e : BizType.values()) {
                map.put(e.getValue(), e.getName());
            }
        }

        public static String getName(int value) {
            return map.get(value);
        }

        public int getValue() {
            return value;
        }

        public String getName() {
            return name;
        }
    }

    Integer customerId;
    Integer money; //单位：分
    Integer bizType;//业务类型
    String sourceId;
    Date createTime;

    public Integer getCustomerId() {
        return customerId;
    }

    public void setCustomerId(Integer customerId) {
        this.customerId = customerId;
    }

    public Integer getBizType() {
        return bizType;
    }

    public void setBizType(Integer bizType) {
        this.bizType = bizType;
    }

    public String getSourceId() {
        return sourceId;
    }

    public void setSourceId(String sourceId) {
        this.sourceId = sourceId;
    }

    public Integer getMoney() {
        return money;
    }

    public void setMoney(Integer money) {
        this.money = money;
    }

    @JsonSerialize(using = DateTimeSerializer.class)
    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public String getBizTypeName() {
        if(bizType != null) {
            return BizType.getName(bizType);
        }
        return "";
    }
}
